package net.yeah.mickey_zhouyou.module.booklist.ui;

import java.awt.BorderLayout;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

public class BookDetailPane extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6391899434586455890L;

	private BookDetailPane() {
		super.setLayout(new BorderLayout());
		final JEditorPane ep = new JEditorPane();
		super.add(new JScrollPane(ep), BorderLayout.CENTER);
		
		ep.getDocument().addDocumentListener(new DocumentListener() {
			public void insertUpdate(DocumentEvent e) {
				System.out.println(1);
				System.out.println(ep.getText());
			}

			public void removeUpdate(DocumentEvent e) {
				System.out.println(2);
				System.out.println(ep.getText());
			}

			public void changedUpdate(DocumentEvent e) {
			}
		});
		ep.addFocusListener(new FocusListener(){
			public void focusGained(FocusEvent e) {
				System.out.println(3);
				System.out.println(ep.getText());
			}

			public void focusLost(FocusEvent e) {
				System.out.println(4);
				System.out.println(ep.getText());
			}});
	}

	private static final BookDetailPane pane = new BookDetailPane();

	public static BookDetailPane getPane() {
		return pane;
	}

}
